home *** CD-ROM | disk | FTP | other *** search
/ Level 2005 Christmas (DVD) / Level_2005-XMAS_134_DVD_Knightshift.iso / Demos / Ski Racing 2006 / setup1.cab / DataCommonShadersNormal_Specular_Basic.NSF < prev    next >
Encoding:
Text File  |  2005-11-03  |  5.4 KB  |  163 lines

  1.  
  2.  
  3. NSFShader Normal_Specular_Basic
  4. {
  5.  
  6.     "This shader skins a model and lights
  7.     it with one directional light + ambient color from light.  
  8.     The lighting is done per pixel with specular using a normal map.
  9.     Specular is modulated with a gloss map
  10.     A gloss map IS required to get the shader work correctly"
  11.  
  12.     //The values for the lights.  Controllers in the application are
  13.     //responsible for updating these values.  Light directions are somewhat
  14.     //misnamed since the represent the light vector from the object not the
  15.     //light direction.
  16.     Global_Attributes
  17.     {
  18.         Attrib_Point4   DirLight1Direction         Hidden  0.0, 0.707, 0.707, 1.0
  19.         Attrib_Point4   DirLight1Color          Hidden  0.886, 0.886, 0.886, 1.0
  20.         Attrib_Point4   AmbLightColor           Hidden  0.886, 0.886, 0.886, 1.0
  21.       Attrib_Point4   CameraWorldLocation      Hidden  0.0, 0.0, 0.0, 1.0        
  22.         Attrib_Point4   NormalSpecAlpha         Hidden  1.0, 1.0, 1.0, 1.0  
  23.  
  24.     }
  25.     // Attribute list
  26.     Attributes
  27.     {
  28.         //The texture for the normals.  
  29.         Attrib_Texture
  30.             NormalMap
  31.             Artist
  32.             0
  33.             "NormalMap.tga"
  34.     }
  35.  
  36.  
  37.  
  38.     // Packing Definition
  39.     PackingDef PosBlendWeightBlendIndicesNormUV0
  40.     {
  41.         PD_Stream    0
  42.             PDP_Position        0    PDT_Float3
  43.             PDP_Normal          3    PDT_Float3
  44.             PDP_Binormal        4    PDT_Float3
  45.             PDP_Tangent         5    PDT_Float3
  46.             PDP_TexCoord0       7    PDT_Float2
  47.     }
  48.  
  49.     
  50.     // Implementation
  51.     Implementation VS11_PS11
  52.     {
  53.         "This implementation is intended for hardware 
  54.          that supports vertex shader version 1.1 and
  55.          pixel shader 1.1."
  56.         
  57.         // Requirements for this implementation
  58.         Requirements
  59.         {
  60.             VSVersion               = v1.1
  61.             UserVersion             = v0.0
  62.             PSVersion               = v1.1
  63.             BinormalTangentMethod   = NBTMethod_ATI
  64.             UsesNIRenderState       = true
  65.             Platform                = DX8|DX9|XBOX
  66.         }
  67.         
  68.         // Packing Definition it uses
  69.         PackingDef    PosBlendWeightBlendIndicesNormUV0
  70.  
  71.         //'Global' render states.  Nothing fancy here.  We set up Z for
  72.         //safety. 
  73.         RenderStates
  74.         { 
  75.             AlphaBlendEnable    = true
  76.             //SrcBlend            = SrcAlpha
  77.             //DestBlend           = InvSrcAlpha
  78.             ZEnable             = ZB_true
  79.             ZWriteEnable        = true
  80.             ZFunc               = LessEqual
  81.         SpecularEnable      = true 
  82.             Lighting            = false   Save
  83.         }
  84.  
  85.         // First pass
  86.         Pass Pass0
  87.         {
  88.             // Vertex shader program
  89.             VSProgram    "Normal_Specular_Basic"
  90.  
  91.             //Vertex Shader constant map.  Mostly commented in the vsh file.
  92.             //For double coverage, we'll state here that we could just use
  93.             //ViewProjTranspose since the SkinWorld part is usually identity,
  94.             //but if our assumption fails then at least positions will be 
  95.             //correct on screen.  Lighting and the warp effect will be off.
  96.             VS_Constantmap
  97.             {
  98.                 CM_Defined      WorldViewProjTranspose      0    0
  99.                 CM_Constant     const_1_1_1_255             4    1    1.0,1.0,1.0,765.01
  100.                 CM_Global       DirLight1Direction          5    1   
  101.                 CM_Global       CameraWorldLocation            6    1
  102.                 CM_Constant     Half                        7    1   0.5,0.5,0.5,0.5   
  103.                 CM_Defined      InvWorldTranspose           8    4
  104.                 CM_Constant     TexProj                     12   1   0.000005,0.000005,1.0,1.0   
  105.         CM_Defined WorldTranspose 16 4
  106.             }
  107.             
  108.          
  109.  
  110.             
  111.             // Sampler stage 0
  112.             Sampler    0    BaseMapSampler
  113.             {
  114.         TSS_Texture        = NTM_Base
  115.  
  116.                 TSAMP_AddressU    = TADDR_Wrap
  117.                 TSAMP_AddressV    = TADDR_Wrap
  118.                 TSAMP_AddressW    = TADDR_Wrap
  119.                 TSAMP_MagFilter    = TEXF_Linear
  120.                 TSAMP_MinFilter    = TEXF_Linear
  121.                 TSAMP_MipFilter    = TEXF_Linear
  122.             }
  123.  
  124.             // Sampler stage 1
  125.             Sampler    1    NormalMapSampler
  126.             {
  127.         TSS_Texture     = <NormalMap>
  128.  
  129.                 TSAMP_AddressU    = TADDR_Wrap
  130.                 TSAMP_AddressV    = TADDR_Wrap
  131.                 TSAMP_AddressW    = TADDR_Wrap
  132.                 TSAMP_MagFilter    = TEXF_Linear
  133.                 TSAMP_MinFilter    = TEXF_Linear
  134.                 TSAMP_MipFilter    = TEXF_Linear
  135.             }
  136.         
  137.         // Sampler stage 2
  138.             Sampler    2    GlossMapSampler
  139.             {
  140.         TSS_Texture     = NTM_Gloss
  141.  
  142.                 TSAMP_AddressU    = TADDR_Wrap
  143.                 TSAMP_AddressV    = TADDR_Wrap
  144.                 TSAMP_AddressW    = TADDR_Wrap
  145.                 TSAMP_MagFilter    = TEXF_Linear
  146.                 TSAMP_MinFilter    = TEXF_Linear
  147.                 TSAMP_MipFilter    = TEXF_Linear
  148.             }
  149.         
  150.  
  151.             PSProgram "Normal_Specular_Basic"
  152.  
  153.             PS_Constantmap
  154.             {
  155.         CM_Global     AmbLightColor      1     1
  156.                 CM_Global       DirLight1Color     2     1         
  157.         CM_Global       NormalSpecAlpha    3     1
  158.             }
  159.         }
  160.     }
  161. }
  162.  
  163.